<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      var obj = { name: "老李", age: 99 };
      var { name: myName, age: myAge } = obj;
      console.log(myName, myAge);

      //   ...扩展运算符
      var obj = { a: 1, b: 25, c: 23 };
      //   过滤解构
      var { a, ...lx } = obj;
      console.log(lx);
      var obj2 = { name: "456" };
      var obj3 = Object.assign(obj, obj2);
      var obj4 = { ...obj, ...obj2 };
      console.log(obj3, obj4);
      //   数组解构
      var arr = [1, 2, 3];
      var [a, b, c] = arr;
      //   交换bc的值
      var [b, c] = [c, b];
      console.log(a, b, c);
      //   数组合并
      var arr2 = [4, 5, 6];
      console.log(arr.concat(arr2)); //新数组
      console.log([...arr, ...arr2]); //新数组
    </script>
  </body>
</html>
